<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
	<head>
		<meta charset="UTF-8">
		<script src="<%=request.getContextPath()%>/resources/js/jquery-1.11.3.min.js" type="text/javascript"></script>
		<script type="text/javascript" src="<%=request.getContextPath()%>/resources/js/jquery-heima-0.0.1.js" ></script>
		<script>
			function del(pid,iid){
				var a = confirm("确定删除吗?");
				if(a==true){
					HM.ajax("<%=request.getContextPath()%>/adminServlet","method=delProduct&pid="+pid,function(data){
						if(data.code==1){
							location.reload();
						}else{
							alert(data.message);
						}
					});
				}
			}
		</script>
		<title>商品列表</title>
		<style type="text/css">
			.a_button_edit{
				background: url(<%=request.getContextPath()%>/resources/img/admin/i_edit.gif) no-repeat;
				display: inline-block;
				width: 18px;
				height: 18px;
			}
			.a_button_del{
				background: url(<%=request.getContextPath()%>/resources/img/admin/i_del.gif) no-repeat;
				display: inline-block;
				width: 18px;
				height: 18px;
			}
			.tr_odd{
				background-color: #CCCCCC;
			}
			.tr_even{
				background-color: #e6e6e6;
			}
			.prod_tr{
				text-align: center;
			}
			.prod_tr:hover{
				background-color: white;
			}
			.this{
				color: red;
			}
		</style>
	</head>
	<body>
		<table cellSpacing="1" cellPadding="0" width="100%" align="center" bgColor="#f5fafe" border="0">
				<tbody>
					<tr>
						<td  align="center" bgColor="#afd1f3">
							<strong>商品列表</strong>
						</TD>
					</tr>
					<tr>
						<td  align="right">
							<a href="add.html" target="mainFrame">添加</a>
						</td>
					</tr>
					<tr>
						<td id="pageProduct" align="center" bgColor="#f5fafe">
							<table cellspacing="0" cellpadding="1" bordercolor="gray" border="1" style=" WIDTH: 100%; WORD-BREAK: break-all;BORDER-COLLAPSE: collapse; WORD-WRAP: break-word">
								<tr style="FONT-WEIGHT: bold; FONT-SIZE: 12pt; HEIGHT: 25px; BACKGROUND-COLOR: #afd1f3;text-align: center;">
									<td width="20%">
										序号
									</td>
									<td  width="15%">
										商品名称
									</td>
									<td  width="40%">
										商品描述
									</td>
									<td  width="7%">
										商品价格
									</td>
									<td  width="5%">
										是否热门
									</td>
									<td >
										商品图片
									</td>
									<td width="6%">
										上/下架
									</td>
									<td width="3%">
										删除
									</td>
								</tr>

								<c:forEach items="${pb.list}" var="i" >
									<tr class="tr_odd prod_tr">
										<td width="20%">
											${i.pid}
										</td>
										<td width="15%">
											${i.pname}
										</td>
										<td align="left" width="40%">
											${i.pdesc}
										</td>
										<td width="7%">
											${i.shop_price}
										</td>
										<td width="5%">
											<c:if test="${i.is_hot==1}">
												是
											</c:if>
											<c:if test="${i.is_hot!=1}">
												否
											</c:if>
										</td>
										<td >
											<img width="40" src="<%=request.getContextPath()%>/${i.pimage}">
										</td>

										<td width="6%" style="padding: 0px;margin: 0px;">
											<form action="<%=request.getContextPath()%>/adminServlet" method="post" style="padding: 0px;margin: 0px;">
												<input type="hidden" name="method" value="updPFlag">
												<input type="hidden" name="pid" value="${i.pid}">
												<c:if test="${i.pflag==0}">
													<input type="hidden" name="pflag" value="1">
													<input type="submit" value="下架" style="width: 100%;height: 45px;background-image: url('<%=request.getContextPath()%>/resources/img/admin/button.jpg');">
												</c:if>
												<c:if test="${i.pflag==1}">
													<input type="hidden" name="pflag" value="0">
													<input type="submit" value="上架" style="width: 100%;height: 45px;background-image: url('<%=request.getContextPath()%>/resources/img/admin/button.jpg');">
												</c:if>
											</form>
										</td>
										<td width="3%">
											<a class="a_button_del" onclick="del('${i.pid}')"></a>
										</td>
									</tr>
								</c:forEach>

							</table>
						</td>
					</tr>
					<tr align="center">
						<td id="pagination" colspan="7">
							<a href="<%=request.getContextPath()%>/adminServlet?method=allProduct&pagenum=1">首页</a>|
							<c:if test="${pb.currentPage>1}">
								<a href="<%=request.getContextPath()%>/adminServlet?method=allProduct&pagenum=${pb.currentPage-1}">上一页</a>|
							</c:if>
							<c:if test="${pb.currentPage<=1}">
								<a href="<%=request.getContextPath()%>/adminServlet?method=allProduct&pagenum=1">上一页</a>|
							</c:if>

							<c:forEach begin="1" end="${pb.totalPage}" var="i" >
								<c:if test="${pb.currentPage==i}">
									<a style="color: #985f0d;font-style: oblique" href="<%=request.getContextPath()%>/adminServlet?method=allProduct&pagenum=${i}">${i}</a>
								</c:if>
								<c:if test="${pb.currentPage!=i}">
									<a href="<%=request.getContextPath()%>/adminServlet?method=allProduct&pagenum=${i}">${i}</a>
								</c:if>
							</c:forEach>

							<c:if test="${pb.currentPage<pb.totalPage}">
								<a href="<%=request.getContextPath()%>/adminServlet?method=allProduct&pagenum=${pb.currentPage+1}">下一页</a>|
							</c:if>
							<c:if test="${pb.currentPage>=pb.totalPage}">
								<a href="<%=request.getContextPath()%>/adminServlet?method=allProduct&pagenum=${pb.totalPage}">下一页</a>|
							</c:if>
							<a href="<%=request.getContextPath()%>/adminServlet?method=allProduct&pagenum=${pb.totalPage}">尾页</a> |
							第${pb.currentPage}页/共${pb.totalPage}页/共${pb.totalCount}条

						</td>
					</tr>
				</tbody>
			</table>
	</body>
</html>
